﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;

namespace ITM495.Lab2
{
    class ResourceHelper
    {
        public static String ReadEmbeddedResource(string name)
        {
            StreamReader sr = null;
            try
            {
                if (String.IsNullOrEmpty(name)) return (null);

                var assembly = Assembly.GetExecutingAssembly();
                var stream = assembly.GetManifestResourceStream(name);
                if (stream == null)
                    throw new ApplicationException("Stream for resource can not be null");

                sr = new StreamReader(stream);
                return (sr.ReadToEnd());
            }
            catch
            {
                return (null);
            }
            finally
            {
                if (sr != null)
                    sr.Close();
            }
        }
    }
}
